package com.xiao.hao.enums;


import cn.hutool.core.collection.CollUtil;
import com.xiao.hao.resp.BaseEnums;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.List;

//用法枚举
@Getter
@AllArgsConstructor
public enum UsageEnum {

    Usage_1("1", "口服"),
    Usage_2("2", "嚼服"),
    Usage_3("3", "外用"),
    Usage_4("4", "眼滴"),
    Usage_5("5", "鼻滴"),
    Usage_6("6", "含服"),
    //    Usage_7("7", "肌肉注射"),
    Usage_8("8", "开水冲服"),
    Usage_9("9", "温水冲服"),
    Usage_10("10", "静脉滴注"),
    Usage_11("11", "静脉滴注"),
    Usage_12("12", "阴道给药"),
    Usage_13("13", "皮下注射");

    private final String code;
    private final String name;

    public static String getNameByValue(String code) {
        for (UsageEnum typeEnum : values()) {
            if (typeEnum.getCode().equals(code)) {
                return typeEnum.getName();
            }
        }
        return null;
    }

    public static List<BaseEnums> getEnumRespList() {
        List<BaseEnums> respList = CollUtil.newArrayList();
        for (UsageEnum baseUnitEnum : values()) {
            respList.add(new BaseEnums(baseUnitEnum.getCode(), baseUnitEnum.getName()));
        }
        return respList;
    }


}
